package offersimple

type MinStack struct {
	s1 []int
}

/** initialize your data structure here. */
func ConstructorMinStack() MinStack {
	return MinStack{
		s1: []int{},
	}
}

func (this *MinStack) Push(x int) {
	if len(this.s1) == 0 {
		this.s1 = append(this.s1, x)
		this.s1 = append(this.s1, x)
	} else {
		min := this.s1[len(this.s1)-1]
		this.s1 = append(this.s1, x)
		if min < x {
			this.s1 = append(this.s1, min)
		} else {
			this.s1 = append(this.s1, x)
		}
	}

}

func (this *MinStack) Pop() {
	this.s1 = this.s1[:len(this.s1)-2]
}

func (this *MinStack) Top() int {
	return this.s1[len(this.s1)-2]
}

func (this *MinStack) Min() int {
	return this.s1[len(this.s1)-1]
}
